﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Forum : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    #region PROPERTIES

    private UserCredentials User
    {
        get { return Session["user"] as UserCredentials; }
        set { Session["user"] = value; }
    }

    #endregion


    public bool DeleteButtonVisible(int topicUserID)
    {
        if (topicUserID == User.UserID || User.UserRole.ToString() == "Admin")
        {
            return true;
        }
        return false;
    }


    protected void ListView1_ItemDeleted(object sender, ListViewDeletedEventArgs e)
    {
        if (e.Exception == null)
        {
            string successMessage = ("The topic has been deleted.");
            Session["successMessage"] = successMessage;
            Response.Redirect("~/Forum.aspx");
        }
        else
        {
            string message = ("An Error Has Occured When Trying To Delete The Topic");
            Session["errorMessage"] = message;
            Response.Redirect(String.Format("~/Topic.aspx?topic={0}", Request.QueryString["topic"]));
        }
    }            
}